//
//  UILabel+Extension.swift
//  Weibo T
//
//  Created by mac on 15/12/1.
//  Copyright © 2015年 陈肖坤. All rights reserved.
//

import UIKit

extension UILabel {

    //便利的构造函数  不能和指定的构造函数重名
    convenience init(title: String,color: UIColor = darkGraysColor,fontSize: CGFloat,margin: CGFloat = 0) {
        self.init()
        text = title
        //设置字体color
        textColor = color
        //设置字体大小
        font = UIFont.boldSystemFontOfSize(fontSize)
        //设置换行
        numberOfLines = 0
        //设置字体居中
        textAlignment = NSTextAlignment.Center
        if margin > 0 {
            preferredMaxLayoutWidth = screenW - 2 * margin
            textAlignment = NSTextAlignment.Left
        }
        //设置大小
        sizeToFit()

    }
    
}
